import 'package:flutter/material.dart';
import 'package:ft_web/config.dart';
import 'package:ft_web/main_tab.dart';

class AppInfo{
  static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
  static BuildContext get context => navigatorKey.currentState.overlay.context;
  static BuildContext materialContext;
}

class App extends StatelessWidget {
  App(){
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '森林旅行',
      debugShowCheckedModeBanner: false,
      navigatorKey: AppInfo.navigatorKey,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        primaryColor: ColorConfig.theamColor,
        primaryColorBrightness: Brightness.light,
      ),
      builder: (context, widget){
        return MediaQuery(
          //设置字体不跟随系统大小改变
          data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
          child: GestureDetector(
            onTap: (){
              FocusScopeNode currentFocus = FocusScope.of(context);
              //点击空白关闭键盘
              if (!currentFocus.hasPrimaryFocus &&currentFocus.focusedChild != null) {
                FocusManager.instance.primaryFocus.unfocus();
              }
            },
            child: widget,
          ),
        );
      },
      home: MainTab()
    );
  }
}
